﻿using LeisureNcre.Helper;
using System;
using System.IO;
using System.Windows.Forms;

namespace LeisureNcre
{
    public partial class UpdateFrm : AntdUI.Window
    {
        private string callBackExeName;   //自动升级完成后，要启动的exe的名称。
        private string callBackPath = ""; //自动升级完成后，要启动的exe的完整路径。        
        private bool startAppAfterClose = false; //关闭升级窗体前，是否启动应用程序。
        private int VersionCode = 0;

        private string _serverIp;  //服务器地址
        private string _serverPort; //端口号

        public UpdateFrm(string serverIP, int serverPort, string _callBackExeName, string title, int oldversioncode)
        {
            InitializeComponent();

            this.VersionCode = oldversioncode;
            DirectoryInfo dir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
            this.callBackExeName = dir.Parent.FullName + "\\" + _callBackExeName;
            //            this.callBackPath = dir.Parent.FullName + "\\" + this.callBackExeName; //自动升级完成后，要启动的exe的完整路径。（1）被分发的程序的可执行文件exe必须位于部署目录的根目录。（2）OAUS的客户端（即整个AutoUpdater文件夹)也必须位于这个根目录。
            this.callBackPath = dir.Parent.FullName + "\\";
           // this.Ti = title;

            UpdateHelper updater = new UpdateHelper(serverIP, serverPort, progressBar1, label1);
            try
            {
                updater.SetBaseParam(callBackPath, callBackExeName, VersionCode);
                updater.GetUpdaterInfo();
            }
            catch (Exception e)
            {
             this.label1.Text = e.Message;
            }

        }
        private void UpdateFrm_Load(object sender, EventArgs e)
        {

        }
    }
}
